{% extends "base.html" %}
{% load static %}
{% block title %} 写文章 {% endblock title %}
{% block content %}

<!-- 写文章表单 -->
<div class="container">
  <div class="row">
    <div class="col-12">
      <br>
      <!-- 提交文章的表单 -->
      <form method="post" action="." enctype="multipart/form-data">  <!-- 添加 enctype -->
        {% csrf_token %}

        <!-- 文章标题 -->
        <div class="form-group">
          <label for="title">文章标题</label>
          <input type="text" class="form-control" id="title" name="title">
        </div>

        <!-- 文章正文 -->
        <div class="form-group">
          <label for="body">文章正文</label>
          <textarea class="form-control" id="body" name="body" rows="12"></textarea>
        </div>

        <br>
        <button type="submit" class="btn btn-primary">完成</button>
      </form>
    </div>
  </div>
</div>

<!-- ✅ 引入 CKEditor 的 JS -->
<script src="{% static 'ckeditor/ckeditor-init.js' %}"></script>
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>

<!-- ✅ 初始化 CKEditor -->
<script>
  CKEDITOR.replace('body', {
    // 可选配置项
    filebrowserUploadUrl: '/ckeditor/upload/',
    filebrowserBrowseUrl: '/ckeditor/browse/',
    height: 400,
  });
</script>

{% endblock content %}
